package threaddemo14;

/**
 * Created by L.jp
 * Description:
 * User: 86189
 * Date: 2022-08-07
 * Time: 16:22
 */
//桌子类(Desk)：定义表示包子数量的变量,定义锁对象变量,定义标记桌子上有无包子的变量
    //利用面向对象的方式把变量封装起来，使用private
public class Desk {
    
    //true表示桌子上有包子，false表示有
    private  boolean flag;
    
    //定义初始包子的总数量
    private int  count;
    //厨师和吃货公用一个锁，所以在这里定义一个锁对象
    private final  Object lock=new Object();
    
    public Desk(){
        this(false,10);
    
    }
    public Desk(boolean flag, int count) {
        this.flag = flag;
        this.count = count;
    }
    
    public boolean isFlag() {
        return flag;
    }
    
    public void setFlag(boolean flag) {
        this.flag = flag;
    }
    
    public int getCount() {
        return count;
    }
    
    public void setCount(int count) {
        this.count = count;
    }
    
    public Object getLock() {
        return lock;
    }
    
    @Override
    public String toString() {
        return "Desk{" + "flag=" + flag + ", count=" + count + ", lock=" + lock + '}';
    }
}
